package com.kai.steering.data.service.entity.domainObject;

import cn.hutool.core.bean.BeanUtil;
import com.kai.steering.data.service.entity.AnswerResult;
import com.kai.steering.data.service.entity.po.AnswerJournal;
import com.kai.steering.data.service.entity.po.Question;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import java.io.Serializable;
import java.util.Date;

/**
 * <pre>
 * 答案 Do对象
 * </pre>
 *
 * @author kai
 * @date 2022-02-23
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@ToString
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "AnswerJournalDO对象", description = "回复日志业务实体")
public class AnswerJournalDO implements Serializable {
    private static final long serialVersionUID = 1L;
    @ApiModelProperty(value = "id")
    private String id;
    @ApiModelProperty(value = "题目ID")
    private String questionId;
    @ApiModelProperty(value = "答案ID")
    private String answerId;
    @ApiModelProperty(value = "用户ID")
    private String userId;
    @ApiModelProperty(value = "回答")
    private String replyAnswer;
    @ApiModelProperty(value = "用户题目ID")
    private String userQuestionId;
    @ApiModelProperty(value = "分类ID")
    private String classificationId;
    @ApiModelProperty(value = "回答详情")
    private String replyAnswerDetails;
    @ApiModelProperty(value = "创建时间")
    private Date creationDatetime;
    @ApiModelProperty(value = "创建人管理员id或者用户id")
    private String founder;
    @ApiModelProperty(value = "存在0删除1")
    private String usable;
    @ApiModelProperty(value = "删除日期")
    private Date deleteDatetime;
    @ApiModelProperty(value = "结果")
    private String result;
    @ApiModelProperty(value = "结果详情")
    private String resultDetails;

    public AnswerJournalDO(AnswerJournal answerJournal) {
        this.convertAnswerJournalDO(answerJournal);
    }
    public AnswerJournalDO  convertAnswerJournalDO(AnswerJournal answerJournal){
        BeanUtil.copyProperties(answerJournal, this);
        return this;
    }
    public AnswerJournalDO(AnswerDO answerDO,QuestionDO questionById, AnswerResult answerResult,UserQuestionDO userQuestionDO){
        this.setQuestionId(answerResult.getQuestionId());
        this.setAnswerId(answerResult.getAnswerId());
        this.setUserId("000000");
        this.setReplyAnswer(answerDO.getAnswer());
        this.setUserQuestionId(userQuestionDO.getUserQuestionId());
        this.setClassificationId(questionById.getClassificationDO().getClassificationId());
        this.setReplyAnswerDetails(answerDO.getContent());
        this.setCreationDatetime(new Date());
        this.setResult(answerResult.getResult() + "");
        this.setResultDetails(answerResult.getResultDetails());
        this.setFounder("000000");
    }

}
